using System;
using System.Collections.Generic;
using System.Text;

namespace GSN.Senders
{
    public class SMSSenderFactory
    {
        public enum SmsProviders { None = -1, ICQ = 0, Skype = 1, ForeverSMS = 2, Magtifun = 3 };

        public static ISMSSender getSMSSender()
        {

            SmsProviders provider = SmsProviders.None;

            try
            {
                provider = (SmsProviders)GSNConfig.getConfigItemInt(GSNConfig.GSN_CONFIG_SMS_PROVIDER);
            }
            catch (ConfigException)
            {
                // probably old version
                return new ICQSMSSender(GSNConfig.getConfigItem(GSNConfig.GSN_CONFIG_ICQ_UIN),
                    GSNConfig.getConfigPasswordItem(GSNConfig.GSN_CONFIG_ICQ_PASSWORD));
            }

            ISMSSender s = null;

            switch (provider)
            {
                case SmsProviders.ICQ:
                    s =  new ICQSMSSender();
                    break;
                case SmsProviders.Skype:
                    s = new SkypeSMSSender();
                    break;
                case SmsProviders.ForeverSMS:
                    //s =  new ForeverSMSSender();
                    break;
                case SmsProviders.Magtifun:
                    s = new MagtifunSender();
                    break;
            }

            if (s != null)
                s.load(GSNConfig.getSmsProviderNode());

            return s;

        }

        public static SmsProviders getSenderType(ISMSSender sender)
        {
            switch (sender.GetType().Name)
            {
                case "ICQSMSSender":
                    return SmsProviders.ICQ;
                case "SkypeSMSSender":
                    return SmsProviders.Skype;
                case "MagtifunSender":
                    return SmsProviders.Magtifun;
            }

            return SmsProviders.None;
        }

    }
}
